<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.wanghua.spring.bean.entity.VisitDetail" %>
<%@ page import="java.util.List" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="com.wanghua.spring.util.StringUtil" %>
<html>
<head>
    <title>访问记录</title>
</head>
<body>
<div style="margin-top:10px;margin-buttom:10px;">${pagination}</div>
<div class="list">
    <table>
        <tr>
            <%
                if("id".equals(request.getAttribute("sort"))){
            %>
            <th style="width:35px">
                <a href="${url}v.sort=id&v.order=${order=='asc'?'desc':'asc'}">编号</a>
            </th>
            <%
                }else{
            %>
            <th class="sortable"><a href="${url}action=listDetail&v.sort=id&v.order=asc">编号</a></th>
            <%
                }
            %>
        </tr>
        <%
            List<VisitDetail> detailList=(List<VisitDetail>) request.getAttribute("detailList");
            DateFormat dateFormat =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            for(int i=0;detailList!=null&&i<detailList.size();i++) {
                VisitDetail d = detailList.get(i);

                out.println("<tr class='" + (i % 2 == 0 ? "even" : "odd") + "'>");
                out.println("   <td>" + d.getId() + "</td>");
                out.println("   <td>" + d.getIp() + "</td>");
                out.println("   <td>" + d.getAddress() + "</td>");

                if (!StringUtil.isNull(d.getUrl())) {
                    out.println("   <td><span style='width:100px;overflow:hidden;' title='" + d.getTitle() + "'><a href=\"" + d.getUrl() + "\" target=_blank>" + d.getTitle() + "</a></span></td>");
                } else {
                    out.println("   <td>&nbsp;</td>");
                }
                if (!StringUtil.isNull(d.getReffer()) && d.getUrl() != d.getReffer()) {
                    out.println("   <td><span style='width:100px;overflow:hidden;' title='" + d.getReffer() + "'><a href=\"" + d.getReffer() + "\" target=_blank>" + d.getReffer() + "</a></span></td>");
                } else {
                    out.println("   <td>&nbsp;</td>");
                }
                out.println("   <td><span style='width:130px;overflow:hidden;' title='" + d.getKeyword() + "'>" + d.getKeyword() + "</span></td>");
                out.println("   <td>" + d.getScreenWidth() + "*" + d.getScreenHeight() + "</td>");
                out.println("   <td>" + d.getColorDepth() + "</td>");
                out.println("   <td>" + d.getAppName() + "&nbsp;</td>");
                out.println("   <td><span style='width:100px;overflow:hidden;' title='" + d.getUserAgent() + "'>" + d.getUserAgent() + "</span></td>");
                out.println("   <td>" + dateFormat.format(d.getDate()) + "</td>");
                out.println("</tr>");
            }
        %>
    </table>
</div>
<div style="margin-top:10px;margin-bottom:10px;">${paginatin}</div>
<script type="text/javascript" src="/status.jsp"></script>
</body>
</html>
